﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Yugi.Client;
using System.ComponentModel;
namespace Yugi.Client.ViewModel
{
    public class ChatModel : INotifyPropertyChanged
    {
        public string from = "";
        public string to = "";
        public ChatType type;
        string content = "";
        string text = "";
        public IInvoke Presenter;
        public MainServerHandler main;
       
        public event PropertyChangedEventHandler PropertyChanged;
        public ChatModel(MainServerHandler m, string f, string t)
        {
            from = f;
            to = t;
            main = m;
        }

        public ChatModel(MainServerHandler m, ChatType t)
        {
            main = m;
            type = t;
        }

        public void AddText(string name, string text)
        {
            Content += name + ":" + text + "\n";
        }

        //public void AddText(ChatType type, string name, string text)
        //{

        //}

        public void SendTextChannel(string s)
        {
            if (type == ChatType.Friend || type == ChatType.Group)
                AddText(main.Login_Model.userlogin.UserName, s);
            main.SendMessageToServer(Common.MSG_GSM.L_Chat_Channel, type.ToString(), main.Login_Model.userlogin.GetUserName(), s);
        }
        public void AddText(string s)
        {
            Content += s + "\n";
        }

      

        public string Content
        {
            get { return content; }
            set
            {
                if (value != content)
                {
                    content = value;
                    OnPropertyChanged("Content");
                }
            }
        }


        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
